package com.woniuxy.kaer.shop.controller;


import cn.hutool.core.bean.BeanUtil;
import com.woniuxy.kaer.commons.jwtUtil.JwtUtil;
import com.woniuxy.kaer.commons.util.Result;
import com.woniuxy.kaer.form.AddOrderForm;
import com.woniuxy.kaer.form.ExchangeProductForm;
import com.woniuxy.kaer.param.AddOrderParam;
import com.woniuxy.kaer.param.ExchangeProductParam;
import com.woniuxy.kaer.shop.mapper.PointProductOrderMapper;
import com.woniuxy.kaer.shop.service.PointProductOrderService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 郭建东
 * @since 2025年02月25日
 */
@RestController
@RequestMapping("/pointProductOrder")
@Api(tags = "积分商品订单管理")
public class PointProductOrderController {

    @Resource
    private PointProductOrderService pointProductOrderservice;

    @Resource
    private JwtUtil jwtUtil;

    //兑换积分商品订单
    @PostMapping("/exchangeProduct")
    @ApiOperation("兑换积分商品")
    public Result exchangeProduct(@RequestBody ExchangeProductForm form, @RequestHeader("token") String token) throws Exception{
        Integer userId = jwtUtil.getUserId(token);
        pointProductOrderservice.exchangeProduct(BeanUtil.toBean(form, ExchangeProductParam.class),userId);
        return Result.succeed("兑换成功",null);
    }


}

